package com.heyqing.medium.day9;

/**
 * ClassName:FindMaxConsecutiveOnes
 * Package:com.heyqing.medium.day9
 * Description:
 *
 * @Date:2024/10/11
 * @Author:Heyqing
 */
public class FindMaxConsecutiveOnes {
    public int findMaxConsecutiveOnes(int[] nums) {
        int max = 0, count = 0;
        for (int i = 0; i < nums.length; i++) {
            int current = nums[i];
            if (current == 1) {
                count++;
            } else {
                max = Math.max(count, max);
                count = 0;
            }
        }
        return Math.max(count, max);
    }
}
